﻿namespace OpenPms.Controllers;
/// <summary>
/// 静态信息
/// </summary>
/// <remarks>
///  Sample request:
/// 
/// 1.拆单时自动排房
/// 2.入住前必须排房
/// 
/// Swagger出错原因：
/// 1.没有http get或者post属性
/// 2.get或者post的属性的名称重复
/// 3.数据类名称重复，比如两个类都包含了data的类
/// </remarks>

[Route("api/[controller]")]
public class StaticInfoController : PmsControllerBase<StaticInfoController>
{ 
    public StaticInfoController(IServiceProvider serviceProvider) : base(serviceProvider)
    {
    }
    /// <summary>
    /// 错误代码
    /// </summary>
    /// <returns></returns>
    [HttpGet(nameof(ErrorCodes))]
    public ResponseError ErrorCodes()
    {
        return new();

    }

    /// <summary>
    /// 来源
    /// </summary>
    /// <returns>Dictionary int,string
    /// </returns>
    [HttpGet(nameof(Sources))]
    public Dictionary<int, string> Sources() =>
        configuration.GetSection(Consts.SectionSource).Get<Dictionary<int,string>>()!;

    /// <summary>
    /// 价格码
    /// </summary>
    /// <returns></returns>
    [HttpGet(nameof(Rates))]
    public async Task<List<TRate>> Rates()
    {
        return await db.Rates.Where(ii => ii.HotelId == HotelId && ii.IsPublish).ToListAsync();
    }
   

}
